/*$(document).ready(function(){
	$.ajaxSetup ({
			cache: false //关闭AJAX相应的缓存
	});

	1、房价添加输入合法性校验
	$.formValidator.initConfig({
			formid:"announcementAdd",
			onerror:function(msg){
				return false;
			},
			onsuccess:function(){
				return true;	//提交表单
			}
	});
	$("#announcement_name").formValidator({onshow:"请输入公告名称，请认真填写",onfocus:"请输入公告名称，必填项",oncorrect:"谢谢您的合作"}).inputValidator({min:1,onerror:"请输入公告名称，请认真填写"});
	$("#id_startDate").formValidator({onshow:"请输入开始日期，请认真填写",onfocus:"请输入开始日期，必填项",oncorrect:"谢谢您的合作"}).inputValidator({min:1,onerror:"请输入开始日期，请认真填写"});
	$("#id_backDate").formValidator({onshow:"请输入结束日期，请认真填写",onfocus:"请输入结束日期，必填项",oncorrect:"谢谢您的合作"}).inputValidator({min:1,onerror:"请输入结束日期，请认真填写"});
	$("#announcement_content").formValidator({onshow:"请输入公告内容，请认真填写",onfocus:"请输入公告内容，必填项",oncorrect:"谢谢您的合作"}).inputValidator({min:1,onerror:"请输入公告内容，请认真填写"});
});*/

//录入信息合法性校验
function validateadd()
{   
   if(document.getElementById("announcement_name").value.replace(/(^\s*)|(\s*$)/g,"").length==0)
   {
      alert("请输入公告名称!");
      document.getElementById("announcement_name").focus();
      return false;
   } 
  
   if(document.getElementById("id_startDate").value.replace(/(^\s*)|(\s*$)/g,"").length==0)
   {
      alert("请输入开始日期!");
      document.getElementById("id_startDate").focus();
      return false;
   } 
   
   if(document.getElementById("id_backDate").value.replace(/(^\s*)|(\s*$)/g,"").length==0)
   {
      alert("请输入结束日期!");
      document.getElementById("id_backDate").focus();
      return false;
   } 
   
   if(document.getElementById("announcement_content").value.replace(/(^\s*)|(\s*$)/g,"").length==0)
   {
      alert("请输入公告内容!");
      document.getElementById("announcement_content").focus();
      return false;
   }
   
   if(!checkSection()){alert("请选择下发单位！");return false;}
   return true;
}

function checkSection(){
	var nodes = $.jstree._reference($("#divOrg")).get_checked(-1, true);
	if(nodes.size() > 0){
		var arr = new Array();
		var idx = 0;
		$.each(nodes, function(i, el) {  
			//if($(el).attr("hasChild")=="false"){
				arr[idx] = $(el).attr("id");
				++idx;
			//}
		});
		$("#receive").val(arr);
		return true;
	}else{
		return false;
	}
}

//全选复选框
function checkAll(form){
  var eSource = window.event.srcElement;
  for (var i=0;i<form.elements.length;i++){
    var e = form.elements[i];
    if (e.Name != eSource.name && e.disabled == false)
       e.checked = eSource.checked;
    }
}

//取消全部选复选框
function unselectall(checkBoxID){
	var selectAllObj = document.getElementById(checkBoxID);
    if(selectAllObj.checked){
 		selectAllObj.checked = selectAllObj.checked&0;
    }
}

function selectall(checkBoxID){
	var selectAllObj = document.getElementById(checkBoxID);
    if(selectAllObj.checked){
 		selectAllObj.checked = selectAllObj.checked&1;
    }
}



function displayCtrl(displayElement,hideElement){
	if(displayElement != ""){
		var displayObj = document.getElementById(displayElement);
		displayObj.style.display = "";
	}
	
	if(hideElement != ""){
		var hideObj = document.getElementById(hideElement);
		hideObj.style.display = "none";
	}	
}